package br.com.webcrm.view;

import java.util.List;

import br.com.webcrm.model.Evento;

@SuppressWarnings("serial")
public class EventoDataModel extends PrimeDataModel<Evento> {

    public EventoDataModel() {
    }

    public EventoDataModel(Object data) {
        super(data);
    }
    
    @SuppressWarnings("unchecked")
	@Override
    public Evento getRowData(String rowKey) {
        //In a real app, a more efficient way like a query by rowKey should be implemented to deal with huge data
        
        List<Evento> eventos = (List<Evento>) getWrappedData();
        
        for(Evento evento : eventos) {
        	String id = ""+evento.getIdEvento();
            if(id.equals(rowKey))
                return evento;
        }
        
        return null;
    }

    @Override
    public String getRowKey(Evento evento) {
        return ""+evento.getIdEvento();
    }
}
                    
